<template>
  <div>
    {{news}}<br>
    {{userid}}<br>
    <table>
      <tr>
        <td>标题</td>
        <td>内容</td>
        <td>操作</td>
      </tr>
      <tr v-for="i in news">
        <td>{{i.title}}</td>
        <td>{{i.content}}</td>
        <td>
          <button @click="opennew(i.id)">查看</button>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  name: "day0404_New",
  data() {
    return {
      news:[],
      userid:localStorage.getItem('userid')
    }
  },
  methods: {
    get_new(){
      this.$axios.get('user/login/').then(res=>{
        this.news = res.data.list
      })
    },
    opennew(id){
      if(this.userid){
        this.$axios.get('user/ZhuCe/?userid='+this.userid+'&newid='+id).then(res=>{
          if(res.data.code == 20010){
            console.log(res.data.code)
            alert(res.data.mes)
          }
        })
      }else {
        alert('请登录')
        this.$router.push('day0404_login')
      }
    }
  },
  mounted() {
    this.get_new()
  }

}
</script>

<style scoped>

</style>
